package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlWsperformance;
import com.ruoyi.sl.service.ISlWsperformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车间绩效信息Controller
 * 
 * @author admin
 * @date 2024-06-16
 */
@RestController
@RequestMapping("/sl/wsperformance")
public class SlWsperformanceController extends BaseController
{
    @Autowired
    private ISlWsperformanceService slWsperformanceService;

    /**
     * 查询车间绩效信息列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthws:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlWsperformance slWsperformance)
    {
        startPage();
        List<SlWsperformance> list = slWsperformanceService.selectSlWsperformanceList(slWsperformance);
        return getDataTable(list);
    }

    /**
     * 导出车间绩效信息列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthws:export')")
    @Log(title = "车间绩效信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlWsperformance slWsperformance)
    {
        List<SlWsperformance> list = slWsperformanceService.selectSlWsperformanceList(slWsperformance);
        ExcelUtil<SlWsperformance> util = new ExcelUtil<SlWsperformance>(SlWsperformance.class);
        util.exportExcel(response, list, "车间绩效信息数据");
    }

    /**
     * 获取车间绩效信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthws:query')")
    @GetMapping(value = "/{performanceId}")
    public AjaxResult getInfo(@PathVariable("performanceId") Long performanceId)
    {
        return success(slWsperformanceService.selectSlWsperformanceByPerformanceId(performanceId));
    }

    /**
     * 新增车间绩效信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthws:add')")
    @Log(title = "车间绩效信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlWsperformance slWsperformance)
    {
        return toAjax(slWsperformanceService.insertSlWsperformance(slWsperformance));
    }

    /**
     * 修改车间绩效信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthws:edit')")
    @Log(title = "车间绩效信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlWsperformance slWsperformance)
    {
        return toAjax(slWsperformanceService.updateSlWsperformance(slWsperformance));
    }

    /**
     * 删除车间绩效信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthws:remove')")
    @Log(title = "车间绩效信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{performanceIds}")
    public AjaxResult remove(@PathVariable Long[] performanceIds)
    {
        return toAjax(slWsperformanceService.deleteSlWsperformanceByPerformanceIds(performanceIds));
    }
}
